<%@ page import="model.Message" %>
<%@ page import="dao.MessageDao" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<center>
    <font size="4"><a href="index.jsp">首页</a></font> &nbsp&nbsp  &nbsp&nbsp  &nbsp&nbsp
    <font size="4"><a href="launch.jsp">发布商品</a></font> &nbsp&nbsp  &nbsp&nbsp  &nbsp&nbsp
    <font size="4"><a href="publisher_message.jsp">消息</a></font> &nbsp&nbsp  &nbsp&nbsp  &nbsp&nbsp
    <font size="4"><a href="userinfo.jsp">个人中心</a></font>&nbsp&nbsp  &nbsp&nbsp  &nbsp&nbsp
</center>
<html>
<%String user= (String) session.getAttribute("name");
String publisher= (String) session.getAttribute("publisher");
String item_name= (String) session.getAttribute("item_name");
String message= request.getParameter("message");
String item_id= (String) session.getAttribute("item_id");
int id=Integer.parseInt(item_id);
%>

<head>
    <meta charset=utf-8/>

    <style type=text/css>

        body{

            background:#eee;
            color:#222;
            font-size:15px;
        }

        img{

            display:block;
            height:10%;
            width:30%;

        }

        .block{

            width:500px;
            height:500px;
            margin:0 auto;
            padding:20px 20px;
            background: honeydew;

        }

        /*提示商品的信息div：*/
        .title{
            border:2px solid #303030;/*黑色边框*/
            float: top;
            margin-bottom:20px;
            padding:8px 12px;
            background: #f6ff0a;
            position:relative;
            width:auto;

        }

        .user{
            border:2px solid #303030;
            float:left;
            clear:both;
            background: darkseagreen;
            margin-bottom:20px;
            padding:8px 12px;
            position:relative;
            width:auto;
        }

        .publisher{
            background: #aeeeee;
            border:2px solid #303030;
            clear:both;
            margin-bottom:20px;
            padding:8px 12px;
            position:relative;
            width:auto;
            float:right;
        }


    </style>

</head>

<body>

<div class="block">
    <div style="overflow-y:auto; overflow-x:hidden; width:500px; height:500px;">

        <div class="title" >
            <font size="3" color="#d2691e" >你正在发起商品：</font>
            <font size="4" color="#ff1493"><%=session.getAttribute("item_name")%></font>
            <font size="3" color="#d2691e" >的聊天：</font></div>
        <%
        MessageDao message1=new MessageDao();
        ArrayList<Message> list = message1.getmessage(user);
        if(list!=null&&list.size()>0){
        for(int i=0;i<list.size();i++){
        Message message2 = list.get(i);
        %>
        <div class="user"><%=message2.getMessage()%></div>

        <%
        }}
        %>

        <%MessageDao message3=new MessageDao();
        ArrayList<Message> list2 = message3.getmessage(publisher);
            if(list2!=null&&list2.size()>0){
            for(int i=0;i<list2.size();i++){
            Message message4 = list2.get(i);
            %>
            <div class="publisher"><%=message4.getMessage()%></div>
            <%
            }}
            %>

    </div>


</div>
</body>
<center>
    <form action="user_Message" method="post">
        <input type="text" name="message" style="width:450px; height:35px;border-radius: 10px";> &nbsp&nbsp
        <input type="submit" value="发送" style="width:50px; height:35px;background: crimson;border-radius: 10px"  >
    </form>
    <font size="2" color="blue"> Created By &#64;冯东旺(取用请注明出去)</font>
</center>


</html>
